{include file='public/meta' }
	<title>评论列表 - 木鱼内容管理系统</title>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
              <div class="layui-inline">
                <label class="layui-form-label">评论查找</label>
                <div class="layui-input-block">
                  <input type="text" name="keywords" id="keywords" placeholder="请输入关键词" autocomplete="off" class="layui-input">
                </div>
              </div>
              
              <div class="layui-inline">
                <button class="layui-btn layuiadmin-btn-useradmin" type="submit" onclick="so()">
                  <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                </button>
              </div>
            </div>
        </div>
        
        <div class="layui-card-body">
            <div style="padding-bottom: 10px;">
                <button class="layui-btn layui-btn-danger layuiadmin-btn-useradmin" onclick="delAll()"><i class="layui-icon layui-icon-delete"></i>批量删除</button>
                <!--<button class="layui-btn layuiadmin-btn-useradmin" onclick="openAll()">批量审核</button>-->
            </div>
            <div class="layui-table-body layui-table-main">
                <table class="layui-table">
                    <thead>
				        <tr>
        					<th class=" layui-table-col-special">
        						<div class="layui-table-cell laytable-cell-checkbox">
        							<input type="checkbox" id="checkAll" onclick="isCheck()">
        						</div>
        					</th>
        					<th><div class="layui-table-cell" align="center"><span>ID</span></div></th>
        					<th><div class="layui-table-cell" align="center"><span>评论会员</span></div></th>
        					<th><div class="layui-table-cell" align="center"><span>所在文章</span></div></th>
        					<th><div class="layui-table-cell" align="center"><span>内容</span></div></th>
        					<th><div class="layui-table-cell" align="center"><span>时间</span></div></th>
        					<th><div class="layui-table-cell" align="center"><span>状态</span></div></th>
        					<th><div class="layui-table-cell" align="center"><span>操作</span></div></th>
				        </tr>
				    </thead>
				    <tbody>
    				{foreach $comment as $v}
    				<tr align="center">
    					<td class="layui-table-col-special">
    						<input type="checkbox" name="fav" value="{$v.id}">
    					</td>
    					<td>{$v.id}</td>
    					
    					<td>{$v.name}</td>
    					<td>{$v.catetitle}</td>
    					
    					<td>{$v.content}</td>
    					<td>{:date("Y-m-d",$v.create_time)}</td>
    					
    					<td><div class="layui-table-cell">
    						<button type="button" class="layui-btn-xs layui-btn layui-btn-{php}echo $v['status']=='已通过' ? 'btn':'danger';{/php}">{$v.status}</button>
    						</div>
    					</td>
    					<td align="center" data-off="true" class="layui-table-col-special">
    					<div class="layui-table-cell">
    						
    						<button type="button" class="layui-btn layui-btn-xs layui-btn-{php}echo $v['status']=='已通过' ? 'danger':'btn';{/php}" onclick="setStatus('{$v.id}')"><i class="layui-icon layui-icon-{php}echo $v['status']=='已通过' ? 'download-circle':'upload-circle';{/php}"></i>{php}echo $v['status']=='已通过' ? '屏蔽':'展现';{/php}</button>
    						<button type="button" class="layui-btn layui-btn-xs layui-btn-danger" onclick="ondel({$v.id})"><i class="layui-icon layui-icon-delete"></i>删除</button>
    						</div>
    					</td>
    				</tr>
    				{/foreach}
    				</tbody>
                </table>
            </div>
        </div>
        
    </div>
</div>

	<!--_footer 作为公共模版分离出去-->
	{include file='public/footer' }
	<!--/_footer /作为公共模版分离出去-->

	<!--请在下方写此页面业务相关的脚本-->
	
	<script type="text/javascript">
  layui.config({
    base: '__ADMINST__layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'useradmin', 'table'], function(){
    var $ = layui.$
    ,form = layui.form
    ,table = layui.table;
  });		
		
	//评论状态
	function setStatus(id){
	    layer.msg("确认要变更状态吗？",{
	        time:5000,
	        shade:0.3,
	        btn:['确认','取消'],
	        yes:function(){
	            $.post("{:url('admin/Comment/setStatus')}",{id:id},function(data){
	                if(data.code == 1){
	                    layer.msg(data.msg,{time:2000},function(){
	                        if(data.url) location.href = data.url;
	                    });
	                }else{
	                    layer.msg(data.msg,{time:2000});
	                }
	            });
	        }
	    });
	}	
		
		
	//删除操作
	function ondel(id){
	    layer.msg("确认删除？",{
	        time:5000,
	        shade:0.3,
	        btn:['删除','取消'],
	        yes:function(){
	            $.post("{:url('admin/Comment/deletes')}",{id:id},function(data){
	                if(data.code == 1){
	                    layer.msg(data.msg,{time:2000},function(){
	                        if(data.url) location.href = data.url;
	                    });
	                }else{
	                    layer.msg(data.msg,{time:2000});
	                }
	            });
	        }
	    });
	}

		
	//批量删除
	function delAll(){
	    var id = $("tbody input:checkbox");
	    var ids = [];
	    for(var i=0;i<id.length;i++){
	        if($(id[i]).is(":checked")){
	            ids += $(id[i]).val()+',';
	        }
	    }
	    var delid = ids;
	    if(delid != "" && delid != null){
	        layer.msg("确认删除？",{
	            time:5000,
	            shade:0.3,
	            btn:['删除','取消'],
	            yes:function(){
	                $.post("{:url('admin/Comment/deletes')}",{id:delid},function(data){
	                    if(data.code == 1){
	                        layer.msg(data.msg,{time:2000},function(){
	                            if(data.url) location.href = data.url;
	                        });
	                    }else{
	                        layer.msg(data.msg,{time:2000});
	                    }
	                });
	            }
	        });
	    }else{
	        layer.msg("当前未选择任何信息！",{icon:2,time:2000});
	    }
	}
	
	//全选功能
	function isCheck(){
	    var IsCheck = document.getElementById("checkAll");
	    if(IsCheck.checked == false){
	        var inputs = $("tbody input[name='fav']");
	        for(var i=0;i<inputs.length;i++){
	            inputs[i].checked = false;
	        }
	    }
	    if(IsCheck.checked == true){
	        var inputs = $("tbody input[name='fav']");
	        for(var i=0;i<inputs.length;i++){
	            inputs[i].checked = true;
	        }
	    }
	}
	
	
	//点击搜索执行
	function so() {
		var keywords = $('#keywords').val();
		if(keywords ==""){
			layer.msg("请输入搜索内容!", {time: 2000});
		}else{
			layer.open({
				type:2,
				area:['100%','100%'],
				content:'{:url('Comment/search')}'+'?keywords='+ keywords+'&t=list',
				end:function(){
					location.reload();
				}
			});
		}
	}
	</script>
	<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>
